const data = [{
        region: '北京',
        revenue: 19010902,
        profit: -1176009
    },
    {
        region: '天津',
        revenue: 10811007,
        profit: 28868
    },
    {
        region: '河北',
        revenue: 1012730,
        profit: -51132
    },
    {
        region: '山西',
        revenue: 1173721,
        profit: -23655
    },
    {
        region: '内蒙古',
        revenue: 770402,
        profit: -41597
    },
    {
        region: '辽宁',
        revenue: 1527876,
        profit: -154888
    },
    {
        region: '吉林',
        revenue: 584896,
        profit: -31756
    },
    {
        region: '黑龙江',
        revenue: 509831,
        profit: -62907
    },
    {
        region: '上海',
        revenue: 35454921,
        profit: -729442
    },
    {
        region: '江苏',
        revenue: 15658697,
        profit: -398678
    },
    {
        region: '浙江',
        revenue: 18956033,
        profit: -333993
    },
    {
        region: '安徽',
        revenue: 2858430,
        profit: -96928
    },
    {
        region: '福建',
        revenue: 5263399,
        profit: -61346
    },
    {
        region: '江西',
        revenue: 3023901,
        profit: -29933
    },
    {
        region: '山东',
        revenue: 3488652,
        profit: -1180
    },
    {
        region: '河南',
        revenue: 1604830,
        profit: -84157
    },
    {
        region: '湖北',
        revenue: 6234896,
        profit: -105656
    },
    {
        region: '湖南',
        revenue: 4697663,
        profit: -91584
    },
    {
        region: '广东',
        revenue: 20884736,
        profit: -952761
    },
    {
        region: '广西',
        revenue: 1862061,
        profit: -53404
    },
    {
        region: '海南',
        revenue: 4154222,
        profit: -250178
    },
    {
        region: '重庆',
        revenue: 6804113,
        profit: -167718
    },
    {
        region: '四川',
        revenue: 5064487,
        profit: -29649
    },
    {
        region: '贵州',
        revenue: 2102699,
        profit: -71977
    },
    {
        region: '云南',
        revenue: 3578494,
        profit: -322459
    },
    {
        region: '西藏',
        revenue: 772099,
        profit: -22767
    },
    {
        region: '陕西',
        revenue: 3925054,
        profit: -84600
    },
    {
        region: '甘肃',
        revenue: 1403770,
        profit: -24689
    },
    {
        region: '青海',
        revenue: 664708,
        profit: -6095
    },
    {
        region: '宁夏',
        revenue: 452711,
        profit: -25409
    },
    {
        region: '新疆',
        revenue: 1401333,
        profit: -76586
    }
];
const scroll = document.getElementById('scroll');

// 将数据添加到滚动容器中
data.forEach(item => {
    const div = document.createElement('div');
    div.classList.add('item');
    div.textContent =
        `${item.region}   :   营业收入: ${item.revenue} 亿元          营业利润: ${item.profit} 亿元`; // 在每个变量之间添加了更多空格
      scroll.appendChild(div);
});

// 获取滚动内容高度
const scrollHeight = document.querySelector('.scroll-content').scrollHeight;

// 滚动完成时的处理函数
function handleScrollEnd() {
    if (scroll.scrollTop >= scrollHeight - scroll.clientHeight) {
        scroll.scrollTop = 0; // 滚动到顶部
    }
}

// 监听滚动事件
scroll.addEventListener('scroll', handleScrollEnd);